<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>Window resize example</title>
    <style>
    body {
        margin: 0;
    }

    div {
        box-sizing: border-box;
        width: 100px;
        height: 100px;
        background-image: url('img/bgtile.png');
        border: 10px solid white;
    }
    </style>
</head>

<body>
    <div>
    </div>
    <script>
    var div = document.querySelector('div');
    var WIDTH = window.innerWidth;
    var HEIGHT = window.innerHeight;
    div.style.width = WIDTH + 'px';
    div.style.height = HEIGHT + 'px';
    window.onresize = function() {
        WIDTH = window.innerWidth;
        HEIGHT = window.innerHeight;
        div.style.width = WIDTH + 'px';
        div.style.height = HEIGHT + 'px';
    }
    </script>
</body>

</html>